package com.cn.crmsystem.service.approveService.impl;

import com.cn.crmsystem.mapper.approveMapper.OverTimeMapper;
import com.cn.crmsystem.pojo.*;
import com.cn.crmsystem.service.approveService.OverTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class OverTimeImpl implements OverTimeService{
	@Autowired OverTimeMapper overTimeMapper;
	//查询领导
	@Override
	public ResultJson selectLeader(Integer userid) {
		ResultJson resultJson=new ResultJson();
		/*String code;
		String msg;
		Integer c=overTimeMapper.selectleaderId(userid);
		User user= new User();
		user=overTimeMapper.selectleader(c);
		if(c>0&&user!=null){
			code="200";
			resultJson.getSuccess(code,user);
		}else{
			msg="失 败";
			resultJson.getFail(msg);
		}*/
		return resultJson;
	}
//插入
	@Override
	public ResultJson OverTimeInsert(Overtime overtime, Integer leader) {
		ResultJson resultJson=new ResultJson();
		/*String code;
		String msg;
		try{
			Integer c=overTimeMapper.InsertOverTime(overtime);
			Integer overtimeid=overtime.getOvertime_Id();
			Integer type=1;
			if(c>0) {
				Integer d=overTimeMapper.InsertApprove(leader,overtimeid,type);
				if (d>0){
					code="200";
					msg = "成  功";
					resultJson.getSuccess(msg,code);
				}else{
					msg = "失败";
					resultJson.getSuccess(msg);
				}
			}else{
				msg = "失 败";
				resultJson.getSuccess(msg);
			}
		}catch (Exception e){
			msg=e.getMessage();
			resultJson.getFail(msg);
		}*/
		return resultJson;
	}
    //查询加班列表
	@Override
	public ResultJson SelectMyOverTime(Integer userid, String method) {
		ResultJson resultJson=new ResultJson();
		/*Map<String,Object> map=new HashMap<>();
		String msg;
		List<Approve> list=new ArrayList<>();
		if(method=="0"){
			list=overTimeMapper.selectMYOverTime(userid);
			if(list!=null) {
				map.put("我发出加班列表",list);
				resultJson.getSuccess("成功",map);
			}else{
				resultJson.getSuccess("失败");
			}
		}else{
			list=overTimeMapper.selectApproveOverTime(userid);
			if(list!=null) {
				map.put("我审核加班列表",list);
				resultJson.getSuccess("成功",map);
			}else{
				resultJson.getSuccess("失败");
			}
		}*/
		return resultJson;
	}
//删除
	@Override
	public ResultJson DeleteOverTime(Integer appid) {
		ResultJson resultJson=new ResultJson();
	/*	String code;
		String msg;
		if(overTimeMapper.DeleteApprove(appid)>0) {
			int overTime=overTimeMapper.OverTimeid(appid);
			if(overTimeMapper.DeleteOverTime(overTime)>0){
				code="200";
				msg = "成功";
				resultJson.getSuccess(msg,code);
			}else{
				msg="失败";
				resultJson.getSuccess(msg);
			}
		}else{
			msg="失败";
			resultJson.getSuccess(msg);
		}*/
		return null;
	}
//更新
	@Override
	public ResultJson UpdateOverTime(Integer appid, Integer state) {
		ResultJson resultJson=new ResultJson();
		String code;
		String msg;
	/*	if(overTimeMapper.UpdateOverTime(appid,state)>0) {
			code="200";
			msg = "成功";
			resultJson.getSuccess(msg,code);
		}else{
			msg="失败";
			resultJson.getSuccess(msg);
		}*/
		return resultJson;
	}
//条件查询
	@Override
	public ResultJson SelectConditionOverTime(Integer userid, String method, String state) {
		ResultJson resultJson=new ResultJson();
	/*	Map<String,Object> map=new HashMap<>();
		Approve ap=new Approve();
		List<Approve> condtion=new ArrayList<>();
		if(method=="0"){
			condtion=overTimeMapper.selectMyCondition(userid,state);
			if(condtion!=null) {
				map.put("我发出加班列表",condtion);
				resultJson.getSuccess("成功",map);
			}else{
				resultJson.getSuccess("失败");
			}
		}else{
			condtion=overTimeMapper.selectApproveCondition(userid,state);
			if(condtion!=null) {
				map.put("我审核加班列表",condtion);
				resultJson.getSuccess("成功",map);
			}else{
				resultJson.getSuccess("失败");
			}
		}*/
		return resultJson;
	}
}
